﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;

namespace Demo20240909.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        public DelegateCommand<string> DialogCommand { get; set; }
        private readonly IDialogService dialogService;

        public MainWindowViewModel(IDialogService dialogService)
        {
            this.dialogService = dialogService;
            DialogCommand = new DelegateCommand<string>(Open);
        }

        private void Open(string obj)
        {
            DialogParameters keys = new DialogParameters();
            keys.Add("Title","弹窗打开后传参");
            dialogService.ShowDialog(obj, keys, callback => 
            {
                if (callback.Result == ButtonResult.OK)
                {
                    string result = callback.Parameters.GetValue<string>("Value");
                }
            });
        }
    }
}
